<% import grails.persistence.Event %>
<%=packageName%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="grame">
		<g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
        <content tag="navbar">
            <li class="dropdown visible-xs">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Actions<span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li><g:link action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
                </ul>
            </li>
        </content>
        <div class="container">
            <div class="row">
                <div class="col-xs-12 col-sm-9">
                    <div id="list-${domainClass.propertyName}" class="table-responsive" role="main">
                        <h1><g:message code="default.list.label" args="[entityName]" /></h1>
                        <g:if test="\${flash.message}">
                            <div class="alert alert-info" role="status">\${flash.message}</div>
                        </g:if>
                        <table class="table table-hover table-condensed">
                        <thead>
                                <tr>
                                <%  excludedProps = Event.allEvents.toList() << 'id' << 'version'
                                    allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
                                    props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && it.type != null && !Collection.isAssignableFrom(it.type) && (domainClass.constrainedProperties[it.name] ? domainClass.constrainedProperties[it.name].display : true) }
                                    Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
                                    props.eachWithIndex { p, i ->
                                        if (i < 6) {
                                            if (p.isAssociation()) { %>
                                    <th><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th>
                                <%      } else { %>
                                    <g:sortableColumn property="${p.name}" title="\${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" />
                                <%  }   }   } %>
                                </tr>
                            </thead>
                            <tbody>
                            <g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
                                <tr>
                                <%  props.eachWithIndex { p, i ->
                                        if (i == 0) { %>
                                    <td><g:link action="show" id="\${${propertyName}.id}">\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</g:link></td>
                                <%      } else if (i < 6) {
                                            if (p.type == Boolean || p.type == boolean) { %>
                                    <td><g:formatBoolean boolean="\${${propertyName}.${p.name}}" /></td>
                                <%          } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
                                    <td><g:formatDate date="\${${propertyName}.${p.name}}" /></td>
                                <%          } else { %>
                                    <td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
                                <%  }   }   } %>
                                </tr>
                            </g:each>
                            </tbody>
                        </table>
                        <div class="pagination">
                            <g:paginate total="\${${propertyName}Count ?: 0}" />
                        </div>
                    </div>
                </div><!--/.col-xs-12.col-sm-9-->

                <div class="hidden-xs col-sm-3" id="sidebar">
                    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                        <div class="panel panel-default">
                            <div class="panel-heading" role="tab" id="sidebar_1">
                                <h4 class="panel-title">
                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapse_1" aria-expanded="true" aria-controls="collapse_1">
                                        Actions
                                    </a>
                                </h4>
                            </div>
                            <div class="panel-collapse collapse in" id="collapse_1" role="tabpanel" aria-labelledby="sidebar_1">
                                <ul class="list-group">
                                    <li class="list-group-item"><g:link action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div><!--/.col-xs-6.col-sm-3-->
            </div>
        </div>
	</body>
</html>
